/***************************************************************************
 * Copyright 2012-2013 TXT e-solutions SpA
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * This work was performed within the IoT_at_Work Project
 * and partially funded by the European Commission's
 * 7th Framework Programme under the contract ICT-257367.
 *
 * Authors:
 *      Salvatore Piccione (TXT e-solutions SpA)
 *
 * Contributors:
 *        Domenico Rotondi (TXT e-solutions SpA)
 **************************************************************************/
package it.txt.ens.core.factory;

import it.txt.ens.core.ENSResource;

import java.net.URI;

/**
 * This interface defines the methods to create {@link ENSResource} objects.
 * 
 * @author Salvatore Piccione (TXT e-solutions SpA - salvatore.piccione AT txtgroup.com)
 * @author Domenico Rotondi (TXT e-solutions SpA - domenico.rotondi AT txtgroup.com)
 *
 */
public interface ENSResourceFactory {
    
    static final String PREFIX = "ens.resource.";
    /**
     * The configuration parameter name that indicates the resource's URI host.
     */
    public static final String HOST = PREFIX + "host";
    /**
     * The configuration parameter name indicating the value of the query parameter
     * {@link ENSResource#NAMESPACE_PARAMETER_NAME} of the resource's URI. 
     */
    public static final String NAMESPACE = PREFIX + "namespace";
    /**
     * The configuration parameter name indicating the value of the query parameter
     * {@link ENSResource#PATTERN_PARAMETER_NAME} of the resource's URI. 
     */
    public static final String PATTERN = PREFIX + "pattern";
    /**
     * The configuration parameter name indicating the resource's URI path.
     */
    public static final String PATH = PREFIX + "path";
    /**
     * The configuration parameter name indicating the resource's URI.
     */
    public static final String URI = PREFIX + "uri";
    /**
     * Create a new {@code ENSResource} object.
     * 
     * @param host the resource's URI host.
     * @param path the resource's URI path.
     * @param namespace the resource's namespace.
     * @param pattern the pattern within the given namespae.
     * @return a new {@code ENSResource} object.
     * @throws IllegalArgumentException if at least one parameter is <code>null</code> or an empty string.
     * @throws URIBuildingException if an error occurred while building an URI using the given parameters.
     */
    public ENSResource create (String host, String path, String namespace, String pattern)
    throws IllegalArgumentException, URIBuildingException;
    
    /**
     * Create a new {@code ENSResource} object using the default path.
     * 
     * @param host the resource's URI host.
     * @param namespace the resource's namespace.
     * @param pattern the pattern within the given namespace.
     * @return a new {@code ENSResource} object.
     * @throws IllegalArgumentException if at least one parameter is <code>null</code> or an empty string.
     * @throws URIBuildingException if an error occurred while building an URI using the given parameters.
     */
    public ENSResource create (String host, String namespace, String pattern) 
    throws IllegalArgumentException, URIBuildingException;
    /**
     * Create a new {@code ENSResource} object.
     * 
     * @param uri the resource's URI compliant with the format <pre>amqp://&lt;host>/&lt;path>?Namespace:&lt;namespace>&amp;Pattern:&lt;pattern></pre>
     * @return a new {@code ENSResource} object.
     * @throws IllegalArgumentException if <code>uri</code> is <code>null</code>
     * @throws URIParseException if the given URI is not compliant with the expected format
     */
    public ENSResource create (URI uri) throws IllegalArgumentException, URIParseException;
}
